package com.avic.rong.fragment;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSmoothScroller;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.avic.rong.BaseFragment;
import com.avic.rong.MainActivity;
import com.avic.rong.R;
import com.avic.rong.activity.login.LoginPhoneActivity;
import com.avic.rong.activity.mine.AccountSettingActivity;
import com.avic.rong.activity.mine.CapitalSubsidiaryActivity;
import com.avic.rong.activity.mine.CollectionActivity;
import com.avic.rong.activity.mine.MemberCardActivity;
import com.avic.rong.activity.mine.MemberDetailActivity;
import com.avic.rong.activity.mine.MyFansActivity;
import com.avic.rong.activity.mine.MyReleaseActivity;
import com.avic.rong.activity.product.OnlineCServiceActivity;
import com.avic.rong.adapter.MineLikeAdapter;
import com.avic.rong.adapter.RollOrderListAdapter;
import com.avic.rong.api.mine.ConverMemberApi;
import com.avic.rong.api.mine.MinePageApi;
import com.avic.rong.auditcertification.activity.EnterpriseSuccessActivity;
import com.avic.rong.auditcertification.activity.MyCertificationActivity;
import com.avic.rong.auditcertification.activity.PersonAuthenticationHomeActivity;
import com.avic.rong.bean.mine.MinePageBean;
import com.avic.rong.course.activity.PeiXunBookShelfActivity;
import com.avic.rong.course.activity.PublishActivity;
import com.avic.rong.course.activity.PublishCardActivity;
import com.avic.rong.questionOrAnswer.activity.PersonalHomeActivity;
import com.avic.rong.shoppingCar.activity.ShoppingCarActivity;
import com.avic.rong.userOrder.activity.MineOrderActivity;
import com.avic.rong.userOrder.adapter.OrderPathVpAdapter;
import com.avic.rong.userOrder.api.CaiLikeApi;
import com.avic.rong.userOrder.api.GetOrderTracesByJsonAllApi;
import com.avic.rong.userOrder.bean.CaiLikeBean;
import com.avic.rong.userOrder.bean.GetOrderTracesByJsonAllBean;
import com.avic.rong.userOrder.event.InformUpdate;
import com.avic.rong.utils.ConstantsUtils;
import com.avic.rong.utils.DateUtils;
import com.avic.rong.utils.DensityUtils;
import com.avic.rong.utils.SharedPreferencesUtil;
import com.avic.rong.utils.TimeUtil;
import com.avic.rong.utils.ToastTools;
import com.avic.rong.wedgit.MyViewPager;
import com.avic.rong.wedgit.RollRecyclerView;
import com.avic.rong.wedgit.StringUtil;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.minato.minastore.BaseResultEntity;
import com.example.minato.minastore.http.HttpManager;
import com.example.minato.minastore.listener.HttpOnNextListener;
import com.luck.picture.lib.decoration.GridSpacingItemDecoration;
import com.luck.picture.lib.dialog.CustomDialog;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class FragmentMine extends BaseFragment implements OnRefreshListener {

    @BindView(R.id.recycler_list)
    public RecyclerView recycler_list;
    @BindView(R.id.iv_setting)
    ImageView ivSetting;
    @BindView(R.id.iv_service_phone)
    ImageView ivServicePhone;
    @BindView(R.id.iv_user_head)
    ImageView ivUserHead;
    @BindView(R.id.tv_user_name)
    TextView tvUserName;
    @BindView(R.id.tv_yu_e)
    TextView tvYuE;
    @BindView(R.id.ll_yu_e)
    LinearLayout llYuE;
    @BindView(R.id.ll_apply_certification)
    LinearLayout llApplyCertification;
    @BindView(R.id.ll_collect)
    LinearLayout llCollect;
    @BindView(R.id.ll_shopping_car)
    LinearLayout llShoppingCar;
    @BindView(R.id.ll_member_card)
    LinearLayout llMemberCard;
    @BindView(R.id.iv_rongrong_huiyuan)
    ImageView ivRongrongHuiyuan;
    @BindView(R.id.tv_activate_member)
    TextView tvActivateMember;
    @BindView(R.id.tv_look_details)
    TextView tvLookDetails;
    @BindView(R.id.tv_all_order)
    TextView tvAllOrder;
    @BindView(R.id.iv_pay_money)
    ImageView ivPayMoney;
    @BindView(R.id.ll_daifukuan)
    LinearLayout llDaifukuan;
    @BindView(R.id.ll_daifahuo)
    LinearLayout llDaifahuo;
    @BindView(R.id.ll_daishouhuo)
    LinearLayout llDaishouhuo;
    @BindView(R.id.ll_jiaoyi_chenggong)
    LinearLayout llJiaoyiChenggong;
    @BindView(R.id.tv_mine_fabu)
    TextView tvMineFabu;
    @BindView(R.id.tv_mine_guanzhu)
    TextView tvMineGuanzhu;
    @BindView(R.id.tv_mine_fensi)
    TextView tvMineFensi;
    @BindView(R.id.tv_mine_kecheng)
    TextView tvMineKecheng;
    @BindView(R.id.tv_mine_jihua)
    TextView tvMineJihua;
    @BindView(R.id.roll_recycler)
    RollRecyclerView rollRecycler;
    @BindView(R.id.view_list_click)
    View viewListClick;

    public int ORDER_ROLL = 1;
    @BindView(R.id.tv_collectNum)
    TextView tv_collectNum;
    @BindView(R.id.tv_shopCarNum)
    TextView tv_shopCarNum;
    @BindView(R.id.tv_memberCardNum)
    TextView tv_memberCardNum;
    @BindView(R.id.tv_waitPay)
    TextView tv_waitPay;
    @BindView(R.id.tv_waitSend)
    TextView tv_waitSend;
    @BindView(R.id.tv_waitGet)
    TextView tv_waitGet;
    /* @BindView(R.id.tv_finish)
     TextView tv_finish;*/
    @BindView(R.id.ll_wuliu)
    LinearLayout ll_wuliu;
    @BindView(R.id.ll_senddemand)
    LinearLayout ll_senddemand;
    @BindView(R.id.ll_sendsupply)
    LinearLayout ll_sendsupply;

    public SmartRefreshLayout srlMine;

    @BindView(R.id.tv_wuliu_time)
    TextView tv_wuliu_time;

    @BindView(R.id.tv_topname)
    TextView tvTopName;
    @BindView(R.id.relativeLayout1)
    RelativeLayout relativeLayout1;
    @BindView(R.id.nest_scrollview)
    public ScrollView nestedScrollView;

    @BindView(R.id.rl_top)
    RelativeLayout rlTop;
    @BindView(R.id.tv_certificationstatu)
    TextView tvStatus;
    @BindView(R.id.ll_user_message)
    LinearLayout llUserMessage;
    @BindView(R.id.ll_mydemand)
    LinearLayout llMydemand;
    @BindView(R.id.ll_mysupply)
    LinearLayout llMysupply;
    @BindView(R.id.iv_vip)
    ImageView ivVip;
    private RollOrderListAdapter rollOrderListAdapter;
    public PopupWindow popupWindow;


    private LinearLayout ll_points;
    private MyViewPager vp_dislog;
    private ImageView iv_close;
    Map<Integer, Integer> map = new HashMap();
    private int selectPosition = -1;
    private View view;

    private ArrayList<CaiLikeBean> listData = new ArrayList<>();
    private MineLikeAdapter mineLikeAdapter;
    private SharedPreferencesUtil sharedPreferencesUtil;

    private ArrayList<GetOrderTracesByJsonAllBean.OrderTracesListBean.TracesListBean> wuliuListData = new ArrayList<>();

    private static final int SCROLL_AD = 0;//会员轮播广告
    public static final int DEFAULT_SCROLL_INTERVAL = 3000;//会员轮播广告间隔时间
    public static final float DEFAULT_SCROLL_ANIMATION_TIME = 500;//会员轮播广告动画时长

    private int nowScrollPosition = 0;
    private AdHandler mHandler;
    private CustomDialog customDialog;
    private boolean isRefresh;
    private MinePageApi minePageApi;
    private String token = "";
    private String imeid;

    //全局定义
    private long lastClickTime = 0L;
    // 两次点击间隔不能少于1000ms
    private static final int FAST_CLICK_DELAY_TIME = 1500;


    private ArrayList<GetOrderTracesByJsonAllBean.OrderTracesListBean.TracesListBean> newWuLiu = new ArrayList<>();
    private String userName;
    private Intent intent;
    private int type;
    private int rongRongStatus;


    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.CART_BROADCAST");
        BroadcastReceiver mItemViewListClickReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String msg = intent.getStringExtra("data");
                if ("refresh".equals(msg)) {
                    refresh(true);
                }
            }
        };
        broadcastManager.registerReceiver(mItemViewListClickReceiver, intentFilter);
    }

    private void scrollVipAdOnce(int position) {
//        if ((wuliuListData.size()-1)==position){
//            rollRecycler
//        }else {
        if (wuliuListData != null && wuliuListData.size() > 1) {
            //平滑滑动到指定位置
            rollRecycler.smoothScrollToPosition(position);
        }
//        }

    }

    private void sendScrollMessage(long delayMillis) {
        mHandler.removeMessages(SCROLL_AD);
        mHandler.sendEmptyMessageDelayed(SCROLL_AD, delayMillis);
    }


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        sharedPreferencesUtil = SharedPreferencesUtil.getInstance(getContext());
    }


    public FragmentMine() {
    }

    public static FragmentMine newInstance(String param1, String param2) {
        FragmentMine fragment = new FragmentMine();
        return fragment;
    }


    @Override
    public void onStart() {
        super.onStart();
        scrollVipAdOnce(nowScrollPosition);//防止滑动一半切到别的页面使滑动完成
        if (mHandler != null) {
            sendScrollMessage(DEFAULT_SCROLL_INTERVAL);
        }
        EventBus.getDefault().register(this);
        Log.e("FragmentMine", "onStart: ");
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        if (rlTop.getVisibility() == View.VISIBLE) {
            rlTop.setVisibility(View.GONE);
            nestedScrollView.fullScroll(View.FOCUS_UP);
        }
        isRefresh = true;
        minePageApi.setArgument(token, imeid);
        minePageApi.setShowProgress(true);
        minePageApi.setCancel(false);
        HttpManager.getInstance().doHttpDeal(minePageApi);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();

    }


    private class AdHandler extends Handler {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);

            switch (msg.what) {
                case SCROLL_AD:
                    nowScrollPosition++;
                    scrollVipAdOnce(nowScrollPosition);
                    sendScrollMessage(DEFAULT_SCROLL_INTERVAL);
                    break;
                default:
                    break;
            }
        }
    }


    private void refresh(boolean flag) {
        token = sharedPreferencesUtil.getLoginToken();
        String encode = Uri.encode(token, "UTF-8");
        Log.e("WCX", " login_token  :" + encode);
        Log.e("WCX", " login_token  :" + token);
//        if (login_stoken != null) {
        minePageApi = new MinePageApi((MainActivity) getActivity(), minePageListener);
        minePageApi.setArgument(SharedPreferencesUtil.getLoginToken(), imeid);
        minePageApi.setShowProgress(flag);
        minePageApi.setCancel(!flag);
        HttpManager.getInstance().doHttpDeal(minePageApi);
//        }
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e("FragmentMine", "onCreate: ");
    }

   /* @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_test, container, false);
        srlMine = rootView.findViewById(R.id.srl_mine);
//        rootView = inflater.inflate(R.layout.fragment_test, container, false);

        ButterKnife.bind(this, rootView);
        intent = new Intent(getActivity(), PublishCardActivity.class);

//        srlMine=rootView.findViewById(R.id.srl_mine);
        imeid = sharedPreferencesUtil.getIMEID();

        srlMine.setEnableLoadMore(false);
        srlMine.setOnRefreshListener(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            nestedScrollView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
                @Override
                public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                    Log.e("onScrollChange", "scrollX: " + scrollX + "  oldScrollX: " + oldScrollX + "  scrollY:" + scrollY + "  oldScrollY：" + oldScrollY);
                    if (oldScrollY > 178 || scrollY > 178) {
                        rlTop.setVisibility(View.VISIBLE);
                        rlTop.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                nestedScrollView.fullScroll(View.FOCUS_UP);
                            }
                        });
                    } else {
                        rlTop.setVisibility(View.GONE);
                    }
                }
            });
        }

        if (!EventBus.getDefault().isRegistered(getContext())) {
            EventBus.getDefault().register(getContext());
        }

        refresh(true);
        initView();

        return rootView;
    }*/


    private int waitGet;

    HttpOnNextListener<BaseResultEntity> minePageListener = new HttpOnNextListener<BaseResultEntity>() {

        @Override
        public void onNext(BaseResultEntity baseResultEntity) {
            if (baseResultEntity.getCode().equals(ConstantsUtils.STATUS_SUCCESS_0000)) {
                MinePageBean data = (MinePageBean) baseResultEntity.getData();
                MinePageBean.MyOrderBean myOrder = data.getMyOrder();
                MinePageBean.MyStatisticalBean myStatistical = data.getMyStatistical();
                MinePageBean.UserBean user = data.getUser();
                userName = user.getUserName();
                sharedPreferencesUtil.setUserName(userName);
                sharedPreferencesUtil.setUserPhoto(user.getLogo());

                waitGet = myOrder.getWaitGet();
                rongRongStatus = data.getRongRongStatus();
                type = data.getType();
                if (rongRongStatus == 0) {
                    tvStatus.setText("申请认证");
                } else if (rongRongStatus == 1) {
                    tvStatus.setText("认证审核中");
                } else if (rongRongStatus == 2) {
                    tvStatus.setText("查看认证"); //通过
                } else {
                    tvStatus.setText("查看认证");   //不通过
                }
//                getActivity().runOnUiThread(new Runnable() {
//                    @Override
//                    public void run() {
                tvTopName.setText(userName);
                tvUserName.setText(userName);
                String logo = user.getLogo();
                        /*if (logo == null) {
                            String userPhoto = SharedPreferencesUtil.getInstance(getContext()).getUserPhoto();
                            logo = userPhoto;

                        }*/
                Log.e("wcx", "userPhoto: " + logo);
                RequestOptions requestOptions = new RequestOptions().error(R.mipmap.deafult_image_header).circleCrop();
                Glide.with(getContext()).applyDefaultRequestOptions(requestOptions).load(logo).into(ivUserHead);

                BigDecimal userMoney = user.getUserMoney();
                tvYuE.setText("余额： " + userMoney.toString());

                tv_collectNum.setText(myStatistical.getFavoritesNum() + "");
                tv_shopCarNum.setText(myStatistical.getCatNum() + "");
                tv_memberCardNum.setText(myStatistical.getMemberCardNum() + "");

                if (data.getIsV()==0){
                    ivVip.setVisibility(View.GONE);
                }else {
                    ivVip.setVisibility(View.VISIBLE);
                }

                if (myOrder.getWaitGet() > 0 && myOrder.getWaitGet() < 100) {
                    tv_waitGet.setVisibility(View.VISIBLE);
                    tv_waitGet.setText(myOrder.getWaitGet() + "");
                } else if (myOrder.getWaitGet() >= 100) {
                    tv_waitGet.setVisibility(View.VISIBLE);
                    tv_waitGet.setText("99+");
                } else if (myOrder.getWaitGet() == 0) {
                    tv_waitGet.setVisibility(View.INVISIBLE);
                }

                if (myOrder.getWaitPay() > 0 && myOrder.getWaitPay() < 100) {
                    tv_waitPay.setVisibility(View.VISIBLE);
                    tv_waitPay.setText(myOrder.getWaitPay() + "");
                } else if (myOrder.getWaitPay() >= 100) {
                    tv_waitPay.setVisibility(View.VISIBLE);
                    tv_waitPay.setText("99+");
                } else if (myOrder.getWaitPay() == 0) {
                    tv_waitPay.setVisibility(View.INVISIBLE);
                }

                if (myOrder.getWaitSend() > 0 && myOrder.getWaitSend() < 100) {
                    tv_waitSend.setVisibility(View.VISIBLE);
                    tv_waitSend.setText(myOrder.getWaitSend() + "");
                } else if (myOrder.getWaitSend() >= 100) {
                    tv_waitSend.setVisibility(View.VISIBLE);
                    tv_waitSend.setText("99+");
                } else if (myOrder.getWaitSend() == 0) {
                    tv_waitSend.setVisibility(View.INVISIBLE);
                }

//                    }
//                });

                wuliuList();
                if (isRefresh) {
                    srlMine.finishRefresh();
                }
            } else {
                if (isRefresh) {
                    srlMine.finishRefresh();
                }
            }
        }

        @Override
        public void onError(Throwable e) {
//            String networkState = NetWorkUtils.getNetworkState(getContext());
            Toast toast = Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
            if (isRefresh) {
                srlMine.finishRefresh();
            }
        }
    };

    //当前显示的item
    private int pos = 0;

    /*  private Handler mHandler = new Handler() {
          @Override
          public void handleMessage(Message msg) {
              super.handleMessage(msg);
              if (msg.what == ORDER_ROLL) {





                  rollRecycler.smoothScrollBy(1, DensityUtils.dp2px(getContext(), 60));
                  pos++;

                  if ((pos + 1) == wuliuListData.size()) {
                      pos = 0;
                      rollRecycler.smoothScrollToPosition(0);
                  }


                     *//* Message message = new Message();
                    message.what = ORDER_ROLL;
                    sHandler.removeMessages(ORDER_ROLL);
                    sHandler.sendMessageDelayed(message, 3000);*//*
                mHandler.sendEmptyMessageDelayed(ORDER_ROLL, 3000);
            }
        }
    };*/


    public void initData() {
        //禁止recyclerview滑动
        recycler_list.setNestedScrollingEnabled(false);
        //订单滚动列表
        LinearLayoutManager manager = new LinearLayoutManager(getContext()) {
            @Override
            public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
                LinearSmoothScroller smoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {
                    // 为了平滑滑动返回：滑过1px时经历的时间(ms)。
                    @Override
                    protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
                        //这里必须返回一个正数，否则会出错
                        float duration = DEFAULT_SCROLL_ANIMATION_TIME / displayMetrics.densityDpi;
                        return duration > 0 ? duration : 1;
                    }
                };
                smoothScroller.setTargetPosition(position);
                startSmoothScroll(smoothScroller);
            }
        };
        rollRecycler.setLayoutManager(manager);
        rollOrderListAdapter = new RollOrderListAdapter(getContext(), wuliuListData);
        rollRecycler.setAdapter(rollOrderListAdapter);


//        //通过一个透明的蒙板来设置点击事件
//        viewListClick.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                showOrderPathDialog((pos % 4));
//                Toast.makeText(getContext(), "pos % 4:" + (pos % 4), Toast.LENGTH_SHORT).show();
//            }
//        });
        rollOrderListAdapter.setOnClickItem(new RollOrderListAdapter.OnClickItem() {
            @Override
            public void OnClickListion(View view, int postion) {
                if (DateUtils.isFastDoubleClick()) return;
                showOrderPathDialog(postion);

            }
        });


        //猜你需要列表
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);

        recycler_list.setLayoutManager(gridLayoutManager);
//        recycler_list.addItemDecoration(new SpaceItemDecoration(0,10,1));
        recycler_list.addItemDecoration(new GridSpacingItemDecoration(2, DensityUtils.dip2px(getContext(), 10), false));
        recycler_list.setLayoutManager(gridLayoutManager);
        mineLikeAdapter = new MineLikeAdapter(getContext(), listData);
        recycler_list.setAdapter(mineLikeAdapter);

        //猜你需要请求
        caiLike();

        orderClick();

        wuliuList();
    }

    @Override
    protected void initView() {
//        rootView = inflater.inflate(R.layout.fragment_test, container, false);
        srlMine = fragmentView.findViewById(R.id.srl_mine);
//        rootView = inflater.inflate(R.layout.fragment_test, container, false);

        ButterKnife.bind(this, fragmentView);
        intent = new Intent(getActivity(), PublishCardActivity.class);

//        srlMine=rootView.findViewById(R.id.srl_mine);
        imeid = sharedPreferencesUtil.getIMEID();

        srlMine.setEnableLoadMore(false);
        srlMine.setOnRefreshListener(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            nestedScrollView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
                @Override
                public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                    Log.e("onScrollChange", "scrollX: " + scrollX + "  oldScrollX: " + oldScrollX + "  scrollY:" + scrollY + "  oldScrollY：" + oldScrollY);
                    if (oldScrollY > 178 || scrollY > 178) {
                        rlTop.setVisibility(View.VISIBLE);
                        rlTop.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                nestedScrollView.fullScroll(View.FOCUS_UP);
                            }
                        });
                    } else {
                        rlTop.setVisibility(View.GONE);
                    }
                }
            });
        }

        if (!EventBus.getDefault().isRegistered(getContext())) {
            EventBus.getDefault().register(getContext());
        }

        refresh(true);
        initData();

//        return rootView;
    }

    @Override
    protected void addListener() {

    }

    @Override
    protected int getContentViewId() {
        return R.layout.fragment_test;
    }

    private void wuliuList() {
        if (!SharedPreferencesUtil.getInstance(getContext()).getLogintoken().isEmpty() && waitGet > 0) {
            Map<String, String> map = new HashMap<>();
            map.put("token", SharedPreferencesUtil.getInstance(getContext()).getLogintoken());
            final GetOrderTracesByJsonAllApi getOrderTracesByJsonAllApi = new GetOrderTracesByJsonAllApi((MainActivity) getContext(), simpleOnNextListenerWuliu);
            getOrderTracesByJsonAllApi.setCache(false);
            getOrderTracesByJsonAllApi.setMap(map);
            HttpManager.getInstance().doHttpDeal(getOrderTracesByJsonAllApi);
        } else {
            ll_wuliu.setVisibility(View.GONE);
        }
    }

    //物流列表
    HttpOnNextListener simpleOnNextListenerWuliu = new HttpOnNextListener<BaseResultEntity>() {
        @Override
        public void onNext(BaseResultEntity subjects) {
            wuliuListData.clear();
            newWuLiu.clear();
            if (!subjects.getCode().equals(ConstantsUtils.STATUS_SUCCESS_0000)) {
                ToastTools.showToast(getContext(), subjects.getMsg());
                if (isRefresh) {
                    srlMine.finishRefresh();
                }
                return;
            }
            GetOrderTracesByJsonAllBean getOrderTracesByJsonAllBean = (GetOrderTracesByJsonAllBean) subjects.getData();
            List<GetOrderTracesByJsonAllBean.OrderTracesListBean> orderTracesList = getOrderTracesByJsonAllBean.getOrderTracesList();
            if (getOrderTracesByJsonAllBean != null && orderTracesList.size() > 0 && orderTracesList != null) {

                if (orderTracesList.get(0).getTracesList() != null && orderTracesList.get(0).getTracesList().size() > 0 && orderTracesList.get(0).getTracesList().get(0).getTraces() != null && orderTracesList.get(0).getTracesList().get(0).getTraces().size() > 0) {
                    GetOrderTracesByJsonAllBean.OrderTracesListBean.TracesListBean.TracesBean tracesBean = orderTracesList.get(0).getTracesList().get(0).getTraces().get(0);
                    if (tracesBean != null) {
                        String timeStamp = null;
                        try {
                            timeStamp = TimeUtil.dateToStamp(tracesBean.getAcceptTime() + "");
                            String time = stampToDate(Long.parseLong(timeStamp));
                            tv_wuliu_time.setText(time);
                        } catch (ParseException e) {
                            e.printStackTrace();

                        }

                        tv_wuliu_time.setVisibility(View.VISIBLE);
                    } else {
                        tv_wuliu_time.setVisibility(View.GONE);
                    }
                }


                for (int i = 0; i < orderTracesList.size(); i++) {
                    List<GetOrderTracesByJsonAllBean.OrderTracesListBean.TracesListBean> tracesList = orderTracesList.get(i).getTracesList();
                    for (GetOrderTracesByJsonAllBean.OrderTracesListBean.TracesListBean tracesListBean : tracesList) {
                        tracesListBean.setProImg(orderTracesList.get(i).getProImg());
                        tracesListBean.setOrderType(orderTracesList.get(i).getOrderType());
                        tracesListBean.setOrderId(orderTracesList.get(i).getOrderId());
                        tracesListBean.setUserAddress(orderTracesList.get(i).getAddress().getProvinceName() + orderTracesList.get(i).getAddress().getCityName() + orderTracesList.get(i).getAddress().getAddress());
                        tracesListBean.setCatName(orderTracesList.get(i).getCatName());
                        tracesListBean.setKeywords(orderTracesList.get(i).getKeywords());
                        tracesListBean.setBiaoZhunImg(orderTracesList.get(i).getBiaoZhunImg());
                        newWuLiu.add(tracesListBean);
                    }
                }

                if (newWuLiu == null) return;
                wuliuListData.addAll(newWuLiu);
                if (wuliuListData != null && wuliuListData.size() == 0) {
                    ll_wuliu.setVisibility(View.GONE);
                } else {
                    ll_wuliu.setVisibility(View.VISIBLE);
                }
                rollOrderListAdapter.notifyDataSetChanged();
           /* if (wuliuListData.size() > 2) {
                mHandler.removeMessages(ORDER_ROLL);
                mHandler.sendEmptyMessageDelayed(ORDER_ROLL, 3000);
            }*/
                mHandler = new AdHandler();
                sendScrollMessage(DEFAULT_SCROLL_INTERVAL);
          /*  Message msg = new Message();
            msg.what = ORDER_ROLL;
            sHandler.sendMessageDelayed(msg, 3000);*/
                if (isRefresh) {
                    srlMine.finishRefresh();
                }
            }


        }


        @Override
        public void onCacheNext(String cache) {


        }


        @Override
        public void onError(final Throwable e) {
            Log.e("cjx", e.getMessage());
            if (isRefresh) {
                srlMine.finishRefresh();
            }
        }
    };

    private void orderClick() {
      /*  tv_waitGet.setText(myOrder.getWaitGet()+"");
        tv_waitPay.setText(myOrder.getWaitPay()+"");
        tv_waitSend.setText(myOrder.getWaitSend()+"");
        tv_finish.setText(myOrder.getFinish()+"");*/
        // 待付款  1   待发货   2    待收货    3     交易成功     4
        Intent intent = new Intent(getContext(), MineOrderActivity.class);
        intent.putExtra(MineOrderActivity.ORDER_JUMP, "mine_home");
        llDaifukuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                intent.putExtra("order_state", 1);
                startActivity(intent);
            }
        });

        llDaifahuo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                intent.putExtra("order_state", 2);
                startActivity(intent);
            }
        });
        llDaishouhuo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                intent.putExtra("order_state", 3);
                startActivity(intent);
            }
        });
        llJiaoyiChenggong.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                intent.putExtra("order_state", 4);
                startActivity(intent);
            }
        });
    }

    private void caiLike() {
        if (!SharedPreferencesUtil.getInstance(getContext()).getLogintoken().isEmpty()) {
            Map<String, String> map = new HashMap<>();
            map.put("token", SharedPreferencesUtil.getInstance(getContext()).getLogintoken());
            final CaiLikeApi caiLikeApi = new CaiLikeApi((MainActivity) getContext(), simpleOnNextListenerCaiLike);
            caiLikeApi.setCache(false);
            caiLikeApi.setMap(map);
            HttpManager.getInstance().doHttpDeal(caiLikeApi);

/*            loading_layout.setOnReloadListener(new LoadingLayout.OnReloadListener() {
                @Override
                public void onReload(View v) {
                    HttpManager.getInstance().doHttpDeal(caiLikeApi);
                    loading_layout.setStatus(LoadingLayout.LOADING);
                }
            });
            loading_layout.setStatus(LoadingLayout.LOADING);*/
        }

    }


    public void showOrderPathDialog(final int postion) {
       /* Bundle bundle = new Bundle();
        bundle.putString("postion", postion+"");

        OrderPathDialogFragment editNameDialog = new OrderPathDialogFragment();
        editNameDialog.setArguments(bundle);
        editNameDialog.show(getFragmentManager(), "EditNameDialog");*/
        View view = getLayoutInflater().inflate(R.layout.order_path_dialog, null);
        commonPop(view);
        ll_points = (LinearLayout) view.findViewById(R.id.ll_points);
        TextView tv_look_allorder = (TextView) view.findViewById(R.id.tv_look_allorder);

        vp_dislog = (MyViewPager) view.findViewById(R.id.vp_dislog);
        iv_close = (ImageView) view.findViewById(R.id.iv_close);

        OrderPathVpAdapter orderPathVpAdapter = new OrderPathVpAdapter(getContext(), wuliuListData);
        orderPathVpAdapter.setPopupWindow(popupWindow);
        vp_dislog.setAdapter(orderPathVpAdapter);

        ll_points.removeAllViews();
        for (int i = 0; i < wuliuListData.size(); i++) {
            View point = LayoutInflater.from(getContext()).inflate(R.layout.item_public_banner_point, null);
            ll_points.addView(point);
        }
        tv_look_allorder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(getContext(), MineOrderActivity.class);
                intent.putExtra(MineOrderActivity.ORDER_JUMP, "mine_home");
                intent.putExtra("order_state", 3);
                startActivity(intent);
                popupWindow.dismiss();
            }
        });
        iv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });


        vp_dislog.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

                int recyclerPosition = postion;
                map.put(recyclerPosition, position);


                if (selectPosition == position % wuliuListData.size()) {
                    return;
                }
                ll_points.getChildAt(position % wuliuListData.size()).setSelected(true);
                if (selectPosition >= 0) {
                    ll_points.getChildAt(selectPosition).setSelected(false);
                }

                selectPosition = position % wuliuListData.size();

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        selectPosition = postion;
        ll_points.getChildAt(selectPosition).setSelected(true);
        vp_dislog.setCurrentItem(postion);


        Iterator iter = map.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            int key = (int) entry.getKey();
            int val = (int) entry.getValue();

            if (postion == key) {
                vp_dislog.setCurrentItem(val);
            }
        }

    }


    private void commonPop(View view) {

        popupWindow = new PopupWindow(view, ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT, false);

        // 产生背景变暗效果
        WindowManager.LayoutParams lp = getActivity().getWindow()
                .getAttributes();
        lp.alpha = 0.4f;
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        getActivity().getWindow().setAttributes(lp);
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        popupWindow.setOutsideTouchable(false);
        popupWindow.setTouchable(true);
        //从下往上弹出动画效果
        popupWindow.setAnimationStyle(R.style.bottomPopupAnimation);
        View llRoot = ((MainActivity) getContext()).getWindow().getDecorView();
        popupWindow.showAtLocation(llRoot, Gravity.CENTER, 0, 0);
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

            // 在dismiss中恢复透明度
            public void onDismiss() {
                WindowManager.LayoutParams lp = getActivity().getWindow()
                        .getAttributes();
                lp.alpha = 1f;
                getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                getActivity().getWindow().setAttributes(lp);
            }
        });
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventShowThread(InformUpdate event) {
        if (event.getEventType() == InformUpdate.CLOSE_DIALOG_INFORM) {
            popupWindow.dismiss();
            wuliuList();
        }
    }

    //猜你需要
    HttpOnNextListener simpleOnNextListenerCaiLike = new HttpOnNextListener<BaseResultEntity>() {
        @Override
        public void onNext(BaseResultEntity subjects) {
            listData.clear();
            if (!subjects.getCode().equals(ConstantsUtils.STATUS_SUCCESS_0000)) {
                ToastTools.showToast(getContext(), subjects.getMsg());
                return;
            }
//            loading_layout.setStatus(LoadingLayout.SUCCESS);
            listData.addAll((ArrayList<CaiLikeBean>) subjects.getData());
            mineLikeAdapter.notifyDataSetChanged();

//            List<HistoryLookBean> data = (List<HistoryLookBean>) subjects.getData();
//            listData.addAll(data);
//            historyLookListAdapter.notifyDataSetChanged();
        }


        @Override
        public void onCacheNext(String cache) {


        }


        @Override
        public void onError(final Throwable e) {
            Log.e("cjx", e.getMessage());
//            if (e instanceof SocketTimeoutException || e instanceof ConnectException) {
//                loading_layout.setStatus(LoadingLayout.NO_NETWORK);
//            } else {
//                loading_layout.setStatus(LoadingLayout.ERROR);
//            }
        }
    };

    @Override
    public void onStop() {
        super.onStop();
        if (mHandler != null) {
            mHandler.removeMessages(SCROLL_AD);
        }
        EventBus.getDefault().unregister(this);
        EventBus.getDefault().removeAllStickyEvents();
    }

    @OnClick({R.id.iv_setting, R.id.iv_service_phone, R.id.iv_user_head, R.id.tv_user_name, R.id.ll_yu_e,
            R.id.ll_apply_certification, R.id.ll_collect, R.id.ll_shopping_car, R.id.ll_member_card,
            R.id.iv_rongrong_huiyuan, R.id.tv_activate_member, R.id.tv_look_details, R.id.tv_all_order,
            R.id.iv_pay_money,
            R.id.tv_mine_fabu, R.id.tv_mine_guanzhu, R.id.tv_mine_fensi, R.id.tv_mine_kecheng, R.id.tv_mine_jihua,
            R.id.ll_senddemand, R.id.ll_sendsupply, R.id.iv_topservice_phone, R.id.iv_topsetting, R.id.ll_mydemand,
            R.id.ll_mysupply})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //我的需求
            case R.id.ll_mydemand:
                intent.putExtra("name", "发布的需求");
                getContext().startActivity(intent);
                break;
            //我的供应
            case R.id.ll_mysupply:
                intent.putExtra("name", "发布的供应");
                getContext().startActivity(intent);
                break;
            //发需求
            case R.id.ll_senddemand:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                Intent senddemand = new Intent(getContext(), PublishActivity.class);
                senddemand.putExtra("type", "发布需求");
                startActivity(senddemand);
                break;
            //发供应
            case R.id.ll_sendsupply:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                Intent sendsupply = new Intent(getContext(), PublishActivity.class);
                sendsupply.putExtra("type", "发布供应");
                startActivity(sendsupply);
                break;
            case R.id.iv_topsetting:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(AccountSettingActivity.queryIntent(getContext()));
                break;
            case R.id.iv_topservice_phone:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(OnlineCServiceActivity.getIntent(getActivity(), "ddd"));
                break;
            //设置
            case R.id.iv_setting:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(AccountSettingActivity.queryIntent(getContext()));
                break;
            //咨询
            case R.id.iv_service_phone:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(OnlineCServiceActivity.getIntent(getActivity(), "ddd"));
                break;
            //用户头像
            case R.id.iv_user_head:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                Intent intent = new Intent(getContext(), PersonalHomeActivity.class);
                startActivity(intent);
                break;
            //用户名称
            case R.id.tv_user_name:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                String useName = tvUserName.getText().toString().trim();
                if (useName.equals("登录/注册") && !SharedPreferencesUtil.isLogin()) {
                    startActivity(LoginPhoneActivity.queryIntent(getContext()));
                }
                break;
            //余额
            case R.id.ll_yu_e:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(CapitalSubsidiaryActivity.queryIntent(getContext()));
                break;
            //申请认证
            case R.id.ll_apply_certification:
                if (rongRongStatus == 0) {
                    startActivity(MyCertificationActivity.queryIntent(getContext()));  //认证列表
                } else {
                    if (type == 0 || type == 1) {
                        startActivity(EnterpriseSuccessActivity.queryIntent(getContext()));// 企业认证
                    } else {
                        startActivity(PersonAuthenticationHomeActivity.queryIntent(getContext()));  //个人认证
                    }
                }
                break;
            //收藏
            case R.id.ll_collect:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(CollectionActivity.queryIntent(getContext()));
                break;
            //购物车
            case R.id.ll_shopping_car:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                Intent intent1 = new Intent(getContext(), ShoppingCarActivity.class);
                getActivity().startActivity(intent1);
                break;
            //会员卡
            case R.id.ll_member_card:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(MemberCardActivity.queryIntent(getContext()));
                break;
            //激活会员
            case R.id.tv_activate_member:
                showDialog();
                break;
            //会员查看详情
            case R.id.tv_look_details:
                intent = new Intent(getContext(), MemberDetailActivity.class);
                startActivity(intent);
//                intent = new Intent(getContext(), PaySucceedActivity.class);
//                startActivity(intent);
//                intent = new Intent(getContext(), UploadProofActivity.class);
//                startActivity(intent);
                break;
            //查看全部订单
            case R.id.tv_all_order:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                intent = new Intent(getContext(), MineOrderActivity.class);
                intent.putExtra(MineOrderActivity.ORDER_JUMP, "mine_home");
                startActivity(intent);
                break;
         /*   //待付款
            case R.id.ll_daifukuan:
                break;
            //代发货
            case R.id.ll_daifahuo:
                break;
            //待收货
            case R.id.ll_daishouhuo:
                break;
            //交易成功
            case R.id.ll_jiaoyi_chenggong:
                break;*/
            //我的发布
            case R.id.tv_mine_fabu:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(MyReleaseActivity.queryIntent(getContext()));
                break;
            //我的关注
            case R.id.tv_mine_guanzhu:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(MyFansActivity.queryIntent(getContext(), 0, "", userName));
                break;
            //  我的粉丝
            case R.id.tv_mine_fensi:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(MyFansActivity.queryIntent(getContext(), 1, "", userName));
                break;
            //我的课程
            case R.id.tv_mine_kecheng:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                Intent intent2 = new Intent(getContext(), MineOrderActivity.class);
                intent2.putExtra("orderType", "培训");
                intent2.putExtra("enterType", "课程");
                startActivity(intent2);
                break;
            //我的书架
            case R.id.tv_mine_jihua:
                if (System.currentTimeMillis() - lastClickTime < FAST_CLICK_DELAY_TIME) {
                    return;
                }
                lastClickTime = System.currentTimeMillis();
                startActivity(PeiXunBookShelfActivity.queryIntent(getContext()));
                break;
        }
    }

    private void showDialog() {
        customDialog = new CustomDialog(getContext(), R.layout.remember_dialog);
        customDialog.show();
        customDialog.setCanceledOnTouchOutside(false);


        EditText et_pwd = customDialog.findViewById(R.id.et_pwd);

        customDialog.findViewById(R.id.bt_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customDialog.cancel();
            }
        });
        customDialog.findViewById(R.id.bt_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String trim = et_pwd.getText().toString().trim();
                if (StringUtil.isEmpty(trim)) {
                    Toast toast = Toast.makeText(getContext(), "激活密码不能为空", Toast.LENGTH_SHORT);
                    toast.setGravity(Gravity.CENTER, 0, 0);
                    toast.show();
                    return;
                } else {
                    ConverMemberApi converMemberApi = new ConverMemberApi((MainActivity) getActivity(), converMemberListener);
                    converMemberApi.setArgument(SharedPreferencesUtil.getLoginToken(), trim);
                    HttpManager.getInstance().doHttpDeal(converMemberApi);
                }
                customDialog.cancel();
            }
        });
        customDialog.findViewById(R.id.img_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customDialog.cancel();
            }
        });
    }

    HttpOnNextListener<BaseResultEntity> converMemberListener = new HttpOnNextListener<BaseResultEntity>() {
        @Override
        public void onNext(BaseResultEntity baseResultEntity) {
            if (baseResultEntity.getCode().equals(ConstantsUtils.STATUS_SUCCESS_0000)) {
                Toast toast = Toast.makeText(getContext(), "兑换成功", Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
            } else {
                Toast toast = Toast.makeText(getContext(), baseResultEntity.getCode() + "    " + baseResultEntity.getMsg(), Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
            }
            customDialog.cancel();
        }
    };

    /*
     * 将时间戳转换为时间
     */
    public String stampToDate(long timeMillis) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd");
        Date date = new Date(timeMillis);
        return simpleDateFormat.format(date);
    }

    @Override
    public void onPause() {
        super.onPause();

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
//        sHandler.removeMessages(ORDER_ROLL);
//        sHandler.removeCallbacksAndMessages(null);
    }

}
